// $Id: request.h 17 2011-04-12 18:05:06Z cedric.shih@gmail.com $
/*
 * Copyright (C) 2010 Cedric Shih <cedric.shih@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef REQUEST_H_
#define REQUEST_H_

#include <sys/queue.h>
#include <sys/types.h>

#include "niohttp.h"
#include "common.h"
#include "headers.h"

struct niohttp_session;

struct niohttp_request {
	char *protocol;
	struct niohttp_version version;
	char *method;
	char *uri;
	struct niohttp_headers *header;

	struct niohttp_session *session;
	TAILQ_ENTRY(niohttp_request) next;
	niohttp_request_cb cb;
	void *cbarg;
};

TAILQ_HEAD(niohttp_request_list, niohttp_request);

int niohttp_request_nset_method(struct niohttp_request *req,
		const char *method, size_t len);

int niohttp_request_nset_uri(struct niohttp_request *req,
		const char *uri, size_t len);

int niohttp_request_nset_protocol(struct niohttp_request *req,
		const char *protocol, size_t len);

int niohttp_request_nset_version(struct niohttp_request *req,
		const char *version, size_t len);

int niohttp_request_format(struct niohttp_request *req,
		struct niobuffer *buffer);

#endif /* REQUEST_H_ */
